// 
//  Main.cs
//  
//  Author:
//       Ray Shaw <demogodyou@gmail.com>
// 
//  Copyright (c) 2009 Ray Shaw(xiaolei)
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 
using System;
using System.Configuration;
using SharpNote.Core.Data;
using SharpNote.Core.Config;
using SharpNote.Core.Entity;
using SharpNote.Core.Command;


namespace Test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			SysConfig.GetInstance ().DbFileName = System.IO.Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "SharpNote.db");
			SysConfig.GetInstance ().DbPassword = "";

			UserInfo newUser = new UserInfo();
			newUser.UserName = "test";
			newUser.SetSignInPassword("test");
			newUser.SetDefaultKey("test", "test");
			newUser.SetPrivateKey("test", "test");
			//newUser.SetDbPassword("test", "test");
			
			Console.WriteLine(UserInfo.CreateNewUser(newUser));
			/*
			Console.Write("input: ");
			string input = Console.ReadLine();
			while (!input.Equals("exit", StringComparison.CurrentCultureIgnoreCase)) {
				string[] parameters = CommandLineParser.Parse (input);
				int len = parameters.Length;

				Console.WriteLine ("-------------------------");
				foreach (string str in parameters) {
					Console.WriteLine (str);
				}
				Console.WriteLine ("-------------------------");

				Console.Write ("input: ");
				input = Console.ReadLine ();
			}
			*/
			
			/*
			Test_UserInfo testUserInfo = new Test_UserInfo();
			Test(testUserInfo);
			*/

						/*
			Test_StringEncryptionHelper strEncryptHelper = new Test_StringEncryptionHelper();
			Test(strEncryptHelper);
			*/

			/*
			Test_NoteInfo testNoteInfo = new Test_NoteInfo();
			Test(testNoteInfo);
			*/

			/*
			UserInfo userInfo = new UserInfo();
			userInfo.Id = Guid.NewGuid().ToString();
			userInfo.SetPrivateKey("I am sal_t.");
			userInfo.SetSignInPassword("I am password.");
			userInfo.SetDbPassword("I am dbPassword.");
			
			string dbPassword = string.Empty;
			bool result = userInfo.GetDbPassword(out dbPassword);
			Console.WriteLine(string.Format("Decrypt dbPassword ok: {0}\ndbPassword: {1}.", result, dbPassword));
			*/

			/*
			string code = DbObjectMappingHelper.GenerateEntityClassCode("select * from NoteInfo", "NoteInfo",
			                                              "NoteInfo");
			using(System.IO.StreamWriter writer = new System.IO.StreamWriter(@"d:\NoteInfo"))
			{
			   writer.WriteLine(code);
			}
			*/


Console.ReadLine ();
		}

		/// <summary>
		/// Start unit test.
		/// </summary>
		/// <param name="testCase">
		/// A <see cref="ITestCase"/>
		/// </param>
		public static void Test (ITestCase testCase)
		{
			Console.WriteLine ("=======================================================================");
			Console.WriteLine ("Test UserInfo");
			DateTime startTime = DateTime.Now;
			Console.WriteLine (string.Format ("start time: {0}", startTime.ToString ("yyyy-MM-dd HH:mm:ss fff")));
			Console.WriteLine ("-----------------------------------------------------------------------");
			bool result = testCase.Test ();

			Console.WriteLine ("-----------------------------------------------------------------------");
			DateTime finishTime = DateTime.Now;
			Console.WriteLine (string.Format ("finish time: {0}, spent time: {1}.", finishTime.ToString ("yyyy-MM-dd HH:mm:ss fff"), finishTime.Subtract (startTime)));
			Console.WriteLine ("Pass The Test: " + result.ToString ());
			Console.WriteLine ("=======================================================================");
		}
	}
}
